<!--规划详情弹框-->
<template>
  <el-dialog
    title="规划详情："
    :visible.sync="detailVisiblesubmit"
    :before-close="confirm"
    width="70%">
    <div style="height:500px;overflow:auto;">
      <bostech-detail :detail-data="detailData"></bostech-detail>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirm()">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {projectDetail} from "@/api/planning/project";
  import getDetailData from "@/mixins/getDetailData";
  import {getfileinfopage} from "@/api/system";
  export default {
    name: "detailDialog",
    mixins: [getDetailData()],
    data() {
      return {

      }
    },
    props: {
      detailVisiblesubmit: {
        type: Boolean,
        default: false
      },
      regId:{
        type: Number,
        default: 0
      }
    },
    created(){
      this.getDetailData(this.regId)
    },
    watch: {
      regId(val) {
        if(val){
          this.getDetailData(val)
        }
      }
    },
    methods: {
      getDetailData(id){
        projectDetail(id).then(response => {
          this.getresultDetail(response);
        })
      },
      async  getresultDetail(response){
        if(response.data.code == '0') {
          var records = response.data.data;
          if(records.fileId!="" && records.fileId !=null) {
            this.multiplefiles = [];
            this.multiplefiles = await this.getfileinfopagetemp(records);
          }
          this.getDetailDataMins(records)
        }
      },
      getfileinfopagetemp(records){
        return new Promise((resolve, reject) => {
          if(records.fileId!="" && records.fileId !=null){
            getfileinfopage(Object.assign({
              current: 1,
              size: 100,
              fileIds:records.fileId
            })).then(response => {
              var multiplefiles = response.data.data.records;
              resolve(multiplefiles);
            }).catch(
            )
          }
        })
      },
      confirm(){
        this.$emit('detailConfirm')
      }
    }
  };
</script>


